/*
 * BtsTerm.java
 *
 * Created on 2 de diciembre de 2007, 01:06
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package bts.back;

import bts.util.DMesg;
import bts.util.BtsDate;
import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 *
 * @author juan
 */
public class BtsTerm {
    
    private String id_term;
    private String name;
    private String creationDate;
    private String lastModificationDate;
    private ArrayList<String> tags; //tags
    private ArrayList<LinkToTerm> links;
    
    /**
     * Creates a new instance of BtsTerm
     */
    public BtsTerm(String name) {
        this.creationDate = BtsDate.getActualDate();
        this.lastModificationDate=this.creationDate;
        this.setName(name);
        this.tags=new ArrayList<String>();
        this.links=new ArrayList<LinkToTerm>();
        DMesg.outln("Created new BTS Term: " + name);
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String[] getTags() {
        return this.tags.toArray(new String[this.tags.size()]);
    }
       
    public void setTags(String str) {
        this.tags.removeAll(this.tags); // vacio todo
        str=str.trim(); // quito espacios en blanco al principio y al final
        StringTokenizer st=new java.util.StringTokenizer(str, ",");
        while(st.hasMoreTokens()){
            this.tags.add(st.nextToken());
        }
        DMesg.outln("Added Tags: "+ str + "; to term " + this.name);
    }
    
    public LinkToTerm[] getLinks() {
        return links.toArray(new LinkToTerm[links.size()]);
    }
    
    public void addLink(LinkToTerm link) {
        this.links.add(link);
    }

    public String getCreationDate() {
        return creationDate;
    }

    public String getLastModificationDate() {
        return lastModificationDate;
    }

    public void setLastModificationDate() {
        this.lastModificationDate = BtsDate.getActualDate();
    }
    
}
